#include <iostream>
using namespace std;



//类模板特化 ————————————————————————template<class T1, class T2>
//特化：对于某些特殊类型，进行特殊化处理
//全特化
template<class T1, class T2>
class Data
{
public:
	Data() { cout << "Data<T1, T2> - 原模板" << endl; }
private:
	T1 _d1;
	T2 _d2;
};

template<>
class Data<int, char>
{
public:
	Data() { cout << "Data<int, char> - 全特化" << endl; }
private:
	int _d1;
	char _d2;
};


//偏特化/半特化：特化部分参数
template<class T1>
class Data<T1, int>
{
public:
	Data() { cout << "Data<T1, int> - 偏特化" << endl; }
private:
	T1 _d1;
	int _d2;
};

//限定模板的类型
//两个参数偏特化为指针类型
template <typename T1, typename T2>
class Data <T1*, T2*>
{
public:
	Data() { 
		cout << typeid(T1).name() << endl;
		cout << typeid(T2).name() << endl;
		cout << "Data<T1*, T2*> - 偏特化" << endl << endl;
		//T1 x1;
		//T2* p1;
	}
private:
};

//传引用
template <typename T1, typename T2>
class Data <T1&, T2&>
{
public:
	Data() {
		cout << typeid(T1).name() << endl;
		cout << typeid(T2).name() << endl;
		cout << "Data<T1&, T2&>" << endl << endl;
	}
private:
};

template <typename T1, typename T2>
class Data <T1&, T2*>
{
public:
	Data() {
		cout << typeid(T1).name() << endl;
		cout << typeid(T2).name() << endl;
		cout << "Data<T1&, T2*>" << endl << endl;
	}
private:
};


int main()
{
	Data<int, int> d1;
	Data<int, char> d2;
	Data<int, double>d3;
	Data<int*, double*>d4;
	Data<int*, int**>d5;
	Data<int&, int&>d6;
	Data<int&, int*>d7;


	return 0;
}
